package com.excel.demo.excel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.excel.demo.excel.mapper.ReadExcelMapper;
import com.excel.demo.excel.model.ReadExcel;
import com.excel.demo.excel.service.ReadExcelService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ljj
 * @since 2022-04-09
 */
@Service
public class ReadExcelServiceImpl extends ServiceImpl<ReadExcelMapper, ReadExcel> implements ReadExcelService {
    private static final Logger LOGGER = LoggerFactory.getLogger(ReadExcelServiceImpl.class);
    @Resource
    private  ReadExcelMapper readExcelMapper;
    @Override
    public Integer saveReadExcel(ReadExcel readExcel) {
        return readExcelMapper.insert(readExcel);
    }

    @Override
    public Integer saveReadExcelBatch(List<ReadExcel> list) {
        return readExcelMapper.insertBatch(list);
    }
    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
    public Integer saveReadExcelBatchAfterDelete(List<ReadExcel> list) {
        readExcelMapper.delectAll();
        return readExcelMapper.insertBatch(list);
    }

    @Override
    public String selectFileName() {
        return readExcelMapper.selectFileName();
    }

    @Override
    public List<String> selectAllCfaddress() {
        return readExcelMapper.selectAllCfaddress();
    }

    @Override
    public List<ReadExcel> selectReadExcelByAddr(String addr) {
        return readExcelMapper.selectReadExcelByAddr(addr);
    }

    @Override
    public List<ReadExcel> selectAllForTabel() {
        return readExcelMapper.selectAllForTabel();
    }

    @Override
    public Integer deleteAll() {
        return readExcelMapper.delectAll();
    }


}
